<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<html>
<head>
<script type="text/javascript">
	function enableCustomer(url) {
		asyncOper(url, "确定要启用这些会员吗");
	}
	function stopCustomer(url) {
		asyncOper(url, "确定要冻结这些会员吗");
	}
	//查看会员详细信息
	function showCustomerDetail(url) {
		commonDetail(url, "detail", "customInfoTableId");
	}
	//查看会员关系树形菜单
	function showCustomerRelationTree() {
		var options = {
				url: "../customerinfo/customerRelationTree_show.do",
				title: "会员树查看",
				showSearch: true,
				searchTitle: "会员编号/手机号/姓名",
				width:500,
				height:500
			};
		return showTree(options);
	}
	
	/**
	 * 展示机构树
	 * @param confirmCallback 弹窗确定按钮回调函数
	 * @param uuid 节点展开属性ID的值
	 * @returns 树对象
	 */
	function showODanInsTree(url){

		var checkedItems = checkSelectedCustom("customInfoTableId", true);
		if(!checkedItems){
			return;
		}
		var options = {
			url: url,
			title: "选择机构",
			confirmCallback: modifyCustomInsUuid,
			showSearch: true,
			searchTitle: "机构代码/名称"
		};
		return showTree(options);
	}
	
	function modifyCustomInsUuid(nodes){
		var checkedItems = checkSelectedCustom("customInfoTableId", true);
		if(!checkedItems){
			return;
		}
        var ids = "";
        for(var i = 0 ; i < checkedItems.length; i++){
            ids = ids + "," + (checkedItems[i]).UUID;
        }
        ids = replaceFirst(ids)

		/*确定按钮回调*/
		if(nodes && nodes.length > 0){
			var ins_cd = nodes[0].ID;
		}
		$.jpajax({
			url: "modifyCustomInsUuid.do",
			data: {custom_uuids: ids, ins_cd: ins_cd},
			success: function(result){
				if(result === true){
					grid.load();
					$.jpmessage.info("APP所属机构修改成功！");
				}else{
					$.jpmessage.error("APP所属机构修改失败！");
				}
			}
		});
	}
    function checkSelectedCustom(tableId, isSingle){
        tableId = tableId || "gridTable";
        var msg, checkedItems = $('#'+tableId).datagrid('getChecked');
        if(checkedItems.length == 0){
            msg = "请至少选择一条记录!";
        }if(msg){
            $.jpmessage.warning(msg);
            return false;
        }
        return checkedItems;
    }
    
    function asyncOper(url, msg){
		commonAsync(url, "customInfoTableId", msg, function(result){
			grid.reload();
		});
	}
</script>
</head>
<body class="easyui-layout list_body">
	<form id="customInfoForm" name="customInfoForm">
		<div class="list_body_north" data-options="region:'north'" border="false">
			<!-- 查询表单 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				<div>
					<span>会员编号:</span>
					<input type="text" id="custom_no" name="custom_no" class="easyui-textbox"/> 
					<span>手机号:</span>
					<input type="text" id="phone" name="phone" class="easyui-textbox"  /> 
					<span>会员名称:</span>
					<input type="text" id="name" name="name" class="easyui-textbox"  /> 
					<span>会员状态:</span>
					<code:codeSelect name="user_st" id="user_st" code_type="USER_ST" showSelect="true" ></code:codeSelect>
					<span>机构号:</span> 
					<input type="text" id="ins_uuid" name="ins_uuid" class="easyui-textbox"  /><br>
					<span>机构名称:</span> 
					<input type="text" id="ins_name" name="ins_name" class="easyui-textbox"  /> 
					<span>推荐人手机号:</span>
					<input type="text" id="sup_custom_uuid" name="sup_custom_uuid" class="easyui-textbox"  />
					<span>推荐人姓名:</span>
					<input type="text" id="sup_custom_name" name="sup_custom_name" class="easyui-textbox"  />
					<span>推荐人会员编号:</span>
					<input type="text" id="sup_custom_no" name="sup_custom_no" class="easyui-textbox" /><br>
					<span>身份证号:</span>
					<input type="text" id="certificate_no" name="certificate_no" class="easyui-textbox"  />
					<span>实名认证状态:</span>
					<code:codeSelect name="realname_auth_st" id="realname_auth_st" code_type="REALNAME_AUTH_ST" showSelect="true"></code:codeSelect>
					<span>实名认证审核状态:</span>
					<code:codeSelect name="realname_audit_st" id="realname_audit_st" code_type="REALNAME_AUDIT_ST" showSelect="true"></code:codeSelect>
					<span>VIP认证状态:</span>
					<code:codeSelect name="vip_st" id="vip_st" code_type="VIP_ST" showSelect="true"></code:codeSelect><br>
					<span>实名认证审核开始日期:</span>
					<input type="text" id="realname_auth_ts_start"  name="realname_auth_ts_start" class="easyui-datebox" data-options="editable:false"/>
					<span>实名认证审核结束日期:</span>
					<input type="text" id="realname_auth_ts_end"  name="realname_auth_ts_end" class="easyui-datebox" data-options="editable:false"/>
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-search" onclick="doSearch()">查询</a>
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-reload" onclick="resetForm()">重置</a>
				</div>
			</div>
			<jiepos:buttonOperateTag menuCode="${menuCode }"></jiepos:buttonOperateTag>
		</div>
		<div data-options="region:'center'" border="false" class="list_body_center">
			<!-- 表格 -->
			<table id="customInfoTableId" fit="true"></table>
		</div>
	</form>
</body>
<script type="text/javascript">
	var grid;
	$(function() {
		/*加载表格数据*/
		grid = $("#customInfoTableId").jpgrid({
			url : "getCustomerInfoListJson.do",
			columns : [ {
				title : "会员编号",
				field : "CUSTOM_NO",
				align : 'center'
			}, {
				title : "会员名称",
				field : "NAME",
				align : 'center'
			}, {
                title : "身份证号",
                field : "CERTIFICATE_NO",
                align : 'center',
				width : 120
		}, {
				title : "会员登录账号状态",
				field : "USER_ST",
				align : 'center',
				width : 120
			}, {
				title : "推荐人会员编号",
				field : "SUP_CUSTOM_NO",
				align : 'center'
			},{
				title : "推荐人",
				field : "SUP_CUSTOM_NAME",
				align : 'center'
			}, {
				title : "APP所属机构",
				field : "INS_NAME",
				align : 'center'
			}, {
				title : "所属地区",
				field : "AREA_CN_NAME",
				align : 'center',
				width : 80
			}, {
				title : "实名认证状态",
				field : "REALNAME_AUTH_ST",
				align : 'center'
			}, {
				title : "实名认证审核状态",
				field : "REALNAME_AUDIT_ST",
				align : 'center'
			}, {
                title: "实名认证审核时间",
                field: "REALNAME_AUTH_TS",
                align: 'center'
            }, {
				title : "VIP认证状态",
				field : "VIP_ST",
				align : 'center'
			}, {
				title : "VIP认证时间",
				field : "VIP_AUTH_TS",
				align : 'center'
			}]
		});
	});

	function doSearch() {
		grid.load({
			phone : $('#phone').val(),
			name : $('#name').val(),
			user_st : $('#user_st').val(),
			ins_uuid : $('#ins_uuid').val(),
			custom_no : $('#custom_no').val(),
			sup_custom_uuid : $('#sup_custom_uuid').val(),
			certificate_no : $('#certificate_no').val(),
			realname_audit_st : $('#realname_audit_st').val(),
			ins_name : $("#ins_name").val(),
			sup_custom_name : $("#sup_custom_name").val(),
			realname_auth_st :$("#realname_auth_st").val(),
            sup_custom_no :$("#sup_custom_no").val(),
			vip_st : $("#vip_st").val(),
            realname_auth_ts_start : $("#realname_auth_ts_start").val(),
            realname_auth_ts_end : $("#realname_auth_ts_end").val()
		});
	}

</script>
</html>
